M=require("ming_node");


const rb=file=>{
     return "https://minglie.gitee.io/ming_node_plugis/src/ming_node_plgins/mingCodeGenerate/template"+file;
}

const remoteStaticFile=[
    "/index.html",
    "/config.js",
    "/App.jsx",
    "/BaseTableList.jsx",
    "/MyTableList.jsx"
];


class MingCodeGenerate {

    constructor() {

    }

    install(app,args){
        app.use(remoteStaticFile,async (req,res)=>{
            res.renderUrl(rb(req.url));
        });


        app.get("/mytableList",(req,res)=>{
            let filter=req.params.filter;
            let filterJson=null;
            if(filter!==null){
                filterJson=JSON.parse(filter);
            }
            console.log(filterJson)
            let r= {
                "code": 0,
                "msg": "success",
                "data": {
                    "dataList": [
                        {
                            "id": 0,
                            "g1": 1,
                            "g2": 0,
                            "g3": 1,
                            "g4": 0
                        },
                        {
                            "id": 1,
                            "g1": 0,
                            "g2": 0,
                            "g3": 0,
                            "g4": 0
                        }
                    ],
                    "total": 2
                }
            };
            res.send(r)
        })

    }

}

module.exports = MingCodeGenerate;